package jun.empdepmanagersystem02.controller;

import jun.empdepmanagersystem02.pojo.Emp;
import jun.empdepmanagersystem02.pojo.Result;
import jun.empdepmanagersystem02.service.EmpService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@Slf4j
@RestController
@RequestMapping("/emps")
public class EmpController {
    @Autowired
    private EmpService empService;

    @GetMapping
    //查询员工列表 包括分页查询 条件查询等
    public Result selectList(Emp.Selector selector) {
        return empService.selectList(selector);
    }

    @GetMapping("/{id}")
    public Result sellectById(@PathVariable Integer id) {
        return empService.selectList(new Emp.Selector(id, true));
    }

    @PutMapping()
    public Result update(@RequestBody Emp emp) {
        return empService.update(emp);
    }


    @DeleteMapping("/{ids}")
    public Result delete(@PathVariable List<Integer> ids) {
        return empService.delete(ids);
    }

    @PostMapping
    public Result insert(@RequestBody Emp emo) {
        return empService.insert(emo);
    }




}

